<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>NetBrain</title>
        <link rel="icon" type="image/ico" href="icon.gif" />
        <link rel="stylesheet" href="resources/css/style.css" />
    </h:head>
    <h:body>
        <h:outputLink id="loginLink" value="javascript:void(0)" onclick="dlg.show()" title="login">	
            <p:graphicImage id="centrar" value="/resources/img/logo_netbrain.png" />
        </h:outputLink>
        <p:growl id="growl" showDetail="true" life="3000" />
        <p:dialog id="dialog" header="Login" widgetVar="dlg" modal="true">
            <h:form>
                <h:panelGrid columns="2" cellpadding="5">
                    <h:outputLabel for="username" value="Nombre del usuario:" />
                    <p:inputText value="#{loginBean.user.username}" 
                                 id="username" required="true" label="username" />

                    <h:outputLabel for="password" value="Contraseña:" />
                    <p:password value="#{loginBean.user.password}" 
                                id="password" required="true" label="password" />

                    <f:facet name="footer">
                        <p:commandButton id="loginButton" value="Ingresar" update=":growl" 
                                         actionListener="#{loginBean.login}" icon="llave" 
                                         oncomplete="handleLoginRequest(xhr, status, args)"/>
                    </f:facet>
                </h:panelGrid>

            </h:form>
        </p:dialog>
        <script type="text/javascript">
            function handleLoginRequest(xhr, status, args) {
                if(args.validationFailed || !args.loggedIn) {
                    jQuery('#dialog').effect("shake", { times:3 }, 100);
                }
            }
        </script>
    </h:body>
</html>

